<template>
	<div class="haowubang">
		<div class="haowubang_header">
			<div class="haowubang_header1">
				<div>日榜</div>
				<div>
					<el-date-picker
					  v-model="value2"
					  align="right"
					  type="date"
					  placeholder="选择日期"
					  :picker-options="pickerOptions">
					</el-date-picker>
				</div>
				<div>数据说明<i class="el-icon-question"></i></div>
			</div>
			<div class="haowubang_header2">
				<span>更新日期：</span>
				<span>2020-10-28 12：07</span>
				<span v-loading.fullscreen.lock="fullscreenLoading" @click="xiazai"><i class="el-icon-printer"></i>导出数据</span>
			</div>
		</div>
		
		<div class="haowubiao">
			<table cellpadding="0" cellspacing="0">
				<thead>
					<tr>
						<th>排名</th>
						<th></th>
						<th>商品</th>
						<th>价格(元)</th>
						<th>抖音人气值</th>
						<th>访客增数量</th>
						<th>访客数</th>
						<th>销量增加</th>
						<th>销量</th>
						<th>操作</th>
					</tr>
				</thead>
				
				<tbody>
					<tr v-for="(item,index) in haowu" :key="index">
						<td>
							<img v-if="index==0" src="../../../../assets/img/jinpai.png" />
							<img v-else-if="index==1" src="../../../../assets/img/yinpai.png" />
							<img v-else-if="index==2" src="../../../../assets/img/tongpai.png" />
							<span v-else>{{index+1}}</span>
						</td>
						<td>
							<router-link :to="'/home/'+luyou+'/shangpinxiangqing'">
								<img :src="item.img" />
							</router-link>
						</td>
						<td>
							<router-link :to="'/home/'+luyou+'/shangpinxiangqing'">
								<span>{{item.name}}</span>
								<span>近30天上榜1次</span>
							</router-link>
						</td>
						<td>
							{{item.shu1 | guolv}}
						</td>
						<td>
							{{item.shu2 | guolv}}
						</td>
						<td>
							{{item.shu3 | guolv}}
						</td>
						<td>
							{{item.shu4 | guolv}}
						</td>
						<td>
							{{item.shu5 | guolv}}
						</td>
						<td>
							{{item.shu6 | guolv}}
						</td>
						<td>
							<img src="../../../../assets/img/zhuangtu.png" />
							<img src="../../../../assets/img/xiaoren.png" />
							<img src="../../../../assets/img/bofang.png" />
						</td>
					</tr>
				</tbody>
			</table>
		</div>
		
		<div class="fenye" style="text-align: center;">
			<el-pagination
			  @size-change="handleSizeChange"
			  @current-change="handleCurrentChange"
			  :hide-on-single-page="yindi"
			  :current-page="currentPage4"
			  :page-sizes="[100, 200, 300, 400]"
			  :page-size="100"
			  layout="total, sizes, prev, pager, next, jumper"
			  :total="4001">
			</el-pagination>
		</div>
		
	</div>
</template>

<script>
	export default{
		name:"haowubang",
		data(){
			return{
				shu:234232,
				luyou:'',
				fullscreenLoading:false,
				
				//分页
				yindi:true,//当数据是由一页时，就不显示分页器
				currentPage4: 1,
				
				column:[
					{title:'排名',key:'id',type:"text"},
					{title:'主图',key:'img',type:"image",width:150,height:100},
					{title:'商品',key:'name',type:"text"},
					{title:'价格(元)',key:'shu1',type:"text"},
					{title:'抖音人气值',key:'shu2',type:"text"},
					{title:'访客增数量',key:'shu3',type:"text"},
					{title:'访客数',key:'shu4',type:"text"},
					{title:'销量增加',key:'shu5',type:"text"},
					{title:'销量',key:'shu6',type:"text"},
				],
				haowu:[
				    {
						id:'0001',
						img:"https://www.koltuita.com/wxxcx/img/val4.png",
						name:'小盟主专享',
						shu1:213423,
						shu2:234,
						shu3:3453523,
						shu4:2342345,
						shu5:45625,
						shu6:64,
				  },
				   {
				      id:'0002',
					  img:'https://www.koltuita.com/wxxcx/img/val1.png',
				      name:'开始没打卡',
				      shu1:456,
				      shu2:23452354,
				      shu3:2354,
				      shu4:34563234,
				      shu5:2354356,
				      shu6:23534,
				  },
				  {
				      id:'0003',
					  img:'https://www.koltuita.com/wxxcx/img/val4.png',
				      name:'可能是肯定非公开',
				      shu1:223434,
				      shu2:45636,
				      shu3:45763643,
				      shu4:235,
				      shu5:356234,
				      shu6:245345,
				  },
				  {
				      id:'0004',
				  	  img:'https://www.koltuita.com/wxxcx/img/val2.png',
				      name:'sdf看可适当放宽',
				      shu1:223434,
				      shu2:45636,
				      shu3:45763643,
				      shu4:235,
				      shu5:356234,
				      shu6:245345,
				  },
				],
				
				//日期选择
				pickerOptions: {
				  disabledDate(time) {
					return time.getTime() > Date.now();
				  },
				  shortcuts: [{
					text: '今天',
					onClick(picker) {
					  picker.$emit('pick', new Date());
					}
				  }, {
					text: '昨天',
					onClick(picker) {
					  const date = new Date();
					  date.setTime(date.getTime() - 3600 * 1000 * 24);
					  picker.$emit('pick', date);
					}
				  }, {
					text: '一周前',
					onClick(picker) {
					  const date = new Date();
					  date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
					  picker.$emit('pick', date);
					}
				  }]
				},
				value1: '',
				value2: '',
			}
		},
		created(){
			this.luyou=this.$route.path.split("/")[2];
		},
		//过滤器
		filters:{
			guolv(shuzi){
			  if(shuzi>0){
				var wan=parseInt(shuzi).toString();
				var qumo=wan%10000;
				//粉丝数改变
				if(wan.length<5){
					shuzi=wan;
				}else if(wan.length>4 && wan.length<=8){
					let fen_si=parseFloat(parseInt(wan/10000))+'.'+qumo.toString().substring(0,2)+'w';
					shuzi=fen_si;
				}else if(wan.length>8){
					let fen_si=parseFloat(parseInt(wan/100000000))+'.'+qumo.toString().substring(0,2)+'亿';
					shuzi=fen_si;
				}
			  }
			  return shuzi
			}
		},
		mounted() {
			
		},
		methods:{
			handleSizeChange(val) {
				console.log(`每页 ${val} 条`);
			},
			handleCurrentChange(val) {
				console.log(`当前页: ${val}`);
			},
			
			//数据导出excel表格
			xiazai(){
				this.fullscreenLoading = true;
				setTimeout(() => {
					this.fullscreenLoading = false;
					this.$message.success("数据导出成功！")
					
					this.table2excel(this.column,this.haowu,"好物榜单")
				}, 2000);
			},
		}
	}
</script>

<style scoped="scoped" lang="scss">
	*{
		margin: 0;
		padding: 0;
	}
	.haowubang{
		
		.haowubang_header{
			padding: 0.8rem 2rem;
			background-color: #fff;
			border-bottom-left-radius:0.1rem ;
			border-bottom-right-radius:0.1rem ;
			
			.haowubang_header1{
				float: left;
				display: flex;
				justify-content: space-between;
				align-items: center;
				
				div:nth-of-type(1){
					color: #666;
					font-size: 0.4rem;
				}
				div:nth-of-type(2){
					color: #666;
					font-size: 0.4rem;
					margin: 0 1rem ;
				}
				div:nth-of-type(3){
					color: #666;
					font-size: 0.4rem;
					cursor: pointer;
					i{
						margin-left:0.2rem ;
					}
				}
				div:nth-of-type(3):hover{
					color: #0091FF;
				}
			}
			.haowubang_header2{
				float: right;
				display: flex;
				justify-content: space-between;
				align-items: center;
				
				span:nth-of-type(1){
					color: #333333;
					font-size: 0.4rem;
				}
				span:nth-of-type(2){
					color: #666666;
					font-size: 0.4rem;
					margin-right:1rem ;
				}
				span:nth-of-type(3){
					color: #666666;
					font-size: 0.4rem;
					padding: 0.1rem 0.3rem;
					border: 1px solid #D4D4D4;
					border-radius:0.1rem ;
					cursor: pointer;
					
					i{
						margin-right:0.2rem ;
					}
				}
				span:nth-of-type(3):hover{
					color: #fff;
					background-color: #0091FF;
				}
				
			}
		}
		.haowubang_header::after{
			content: "";
			display: block;
			clear: both;
		}
		
		.haowubiao{
			margin-top:1rem ;
			background-color: #fff;
			border-radius:0.1rem ;
			
			table{
				padding: 0.4rem 0.8rem;
				width: 100%;
				
				th{
					color: #333333;
					font-size: 0.42rem;
					padding: 0.8rem 0;
					text-align: center;
					font-weight: normal;
				}
				th:nth-of-type(3){
					text-align: left;
					width: 12rem;
				}
				td{
					padding: 0.8rem 0;
					color: #666666;
					font-size: 0.4rem;
					text-align: center;
				}
				tr:hover td{
					background-color: rgba(229,244,255,1);
				}
				td:nth-of-type(2){
					img{
						width: 4rem;
						height: 2.5rem;
					}
				}
				
				td:nth-of-type(3) a{
					color: #666666;
					text-decoration: none;
					display: flex;
					align-items: center;
					span:nth-of-type(1){
						display: block;
						overflow : hidden;
						text-overflow: ellipsis;
						display: -webkit-box; 
						-webkit-line-clamp: 1; /* 可以显示的行数，超出部分用...表示*/
						-webkit-box-orient: vertical;
					}
					span:nth-of-type(2){
						display: inline;
						padding: 0.1rem 0.3rem;
						border: 1px solid #999999;
						border-radius:0.1rem ;
						font-size: 0.35rem;
						margin-left:0.2rem ;
						white-space: nowrap;//强制不换行
					}
				}
				td:nth-of-type(3) a:hover{
					color: #0091FF;
				}
				
				td:last-child{
					color: #0091FF;
					font-size: 0.5rem;
					
					img{
						width: 0.5rem;
						cursor: pointer;
					}
					img:not(:last-child){
						margin-right:0.3rem ;
					}
				}
				
			}
		}
		
	}
</style>
